/*
 * Copyright (C) 2009 Ionut Dediu <deionut@yahoo.com>
 *
 * Licensed under the GNU General Public License Version 2
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

// CamFilter.h

#ifndef __CAM_FILTER_H__
#define __CAM_FILTER_H__

#include <ecam.h>				// CCamera
#include <fbs.h>				// CFbsBitmap

#include "SmartStream.h"		// MSmartFilter, MPipelineMgr
#include "CommFilter.h"
#include "jpegencoder.h"

class CCamFilter : public CBase, public MStreamFilter, public MCameraObserver
{
public:
	static CCamFilter* NewL();
    static CCamFilter* NewLC();
    ~CCamFilter();

	void Open(MStreamManager* aMgr);
	void AttachCommFilter(CCommFilter* aCommFilter);
	void Start();
	void Close();

	// New methods:
	void EnumerateVideoResolutions(TInt aCameraIndex, RArray<TSize>& aArray);
	void EnumerateVideoFrameRates(TInt aCameraIndex, TInt aResolutionIndex, RArray<TReal32>& aArray);
	static TInt CamerasAvailable();
	// From MCameraObserver:
	void ReserveComplete(TInt aError);
	void PowerOnComplete(TInt aError);
	void ViewFinderFrameReady(CFbsBitmap& aFrame);
	void ImageReady(CFbsBitmap* aBitmap, HBufC8* aData, TInt aError);
	void FrameBufferReady(MFrameBuffer* aFrameBuffer, TInt aError);

private:

	CCamFilter();
    void ConstructL();

	// Member variables
	// Filter data:
	MStreamManager* iStreamMgr;
	CCommFilter* iCommFilter;
	CJpegEncoder* iJpegEncoder;
	// Camera data:
	CCamera* iCamera;
};

#endif//__CAM_FILTER_H__
